home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Graphic Gems I, II & III (C_C++) / Graphics Gems C Code.sea / GemsI / Src / AALines / AAMain.c < prev    next >
Text File  |  1992-06-16  |  2KB  |  64 lines

  1. /*  FILENAME:  AAMain.c  [revised 17 AUG 90]
  2.  
  3.     AUTHOR:  Kelvin Thompson
  4.  
  5.     DESCRIPTION:  Calling routine for anti-aliased line renderer.
  6.       This routine calls the line renderer to draw a single
  7.       anti-aliased line into a small frame buffer.  The
  8.       routine then dumps the frame buffer to a Utah RLE file
  9.       'anti.rle'.
  10.  
  11.     LINK WITH:
  12.       utah.h -- Definitions for friendly Utah RLE front end.
  13.       AALines.h -- Shared tables, symbols, etc. for renderer.
  14.       AALines.c -- Rendering code.
  15.       AATables.c -- Table initialization.
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <math.h>
  20. #include "AALines.h"
  21. #include "utah.h"
  22.  
  23.  
  24.  
  25. main ( argc, argv )
  26. int argc;
  27. char *argv[];
  28. {
  29. int i;
  30. char *scanptr;
  31. int x1,y1,x2,y2;
  32.  
  33. /* initialize frame buffer and look-up tables */
  34. Anti_Init();
  35.  
  36. /* set line endpoints */
  37. x1 =  2;  y1 =  2;
  38. x2 = 25;  y2 = 55;
  39.  
  40. /* render anti-aliased line to a frame buffer */
  41. Anti_Line( x1,y1, x2,y2 );
  42.  
  43.  
  44. /* The code below dumps the frame buffer to a Utah RLE file.
  45. ** It should be pretty easy to rewrite so that it dumps to
  46. ** any other kind of output file...or straight to a display
  47. ** device.  The frame buffer is an array of characters
  48. ** starting at 'fbuff' with size 'xpix' by 'ypix'.  */
  49.  
  50.   {
  51.   /* thanks to A.T. Campbell for the friendly front end */
  52.   UTAH_FILE *picout;
  53.   picout = utah_write_init( "anti.rle", xpix, ypix );
  54.   if ( picout == NULL )
  55.     { perror("anti.rle");  exit(1); }
  56.   for ( i=0; i<ypix; i++ )
  57.     {
  58.     scanptr = &fbuff[i*xpix];
  59.     utah_write_rgb( picout, scanptr, scanptr, scanptr );
  60.     }
  61.   utah_write_close(picout);
  62.   }
  63. }
  64.